<template>
	<view>
		<view class="goods-item">
			<!-- 左边的盒子 -->
			<view class="goods-item-left">
				<radio checked color="#DD524D"></radio>
				<image :src="goods.goods_small_logo || defaultPic" class="goods-pic"></image>
			</view>
			<!-- 右边的盒子 -->
			<view class="goods-item-right">
				<!-- 商品名称 -->
				<view class="goods-name">
					{{goods.goods_name}}
				</view>
				<view class="goods-info-box">
					<view class="goods-price">
						￥{{goods.goods_price | tofixed}}
					</view>
					<!-- 最小值为1，value动态绑定商品数量 -->
					<uni-number-box :min="1" :value="goods.goods_count" v-if="showNum"></uni-number-box>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		props: {
			goods: {
				type: Object,
				default: {}
			},
			showNum:{
				type:Boolean,
				default:false 
			}

		},
		name: "my-goods",
		data() {
			return {
				defaultPic: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fi0.hdslb.com%2Fbfs%2Farticle%2F1f689110ebad57e991c4ddec95e831c30ea0b60e.png&refer=http%3A%2F%2Fi0.hdslb.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1652948002&t=76d1c1b70ee1d165f9fe4c362703d2f7'
			};
		},
		filters: {
			tofixed(num) {
				return Number(num).toFixed(2)
			}
		},
		
	}
</script>

<style lang="scss">
	.goods-item {
		display: flex;
		padding: 10px 5px;
		border-bottom: 1px solid #A5A5A5;

		.goods-item-left {
			margin-right: 5px;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.goods-pic {
				width: 100px;
				height: 100px;
				display: block;
			}
		}

		.goods-item-right {
			display: flex;
			flex-direction: column;
			justify-content: space-between;

			.goods-name {
				font-size: 13px;
			}

			.goods-info-box {
				display: flex;
				justify-content: space-between;
				align-items: center;
				
				.goods-price {
					color: #909399;
					font-size: 16px;
				}
			}
		}
	}
</style>
